//
//  Person.m
//  FRP_OC
//
//  Created by DeLong Yang on 2017/8/7.
//  Copyright © 2017年 DeLongYang. All rights reserved.
//

#import "Person.h"

@implementation Person

- (void)eat1
{
    NSLog(@"%s",__FUNCTION__);
}

- (void)sleep1
{
    NSLog(@"%s",__FUNCTION__);
}

- (Person *)eat2
{
    NSLog(@"%s",__FUNCTION__);
    return self;
}
- (Person *)sleep2
{
    NSLog(@"%s",__FUNCTION__);
    return self;
}


//
- (void (^)())eat3
{
    void (^eat3Block)() = ^(){
        NSLog(@"%s",__FUNCTION__);
    };
    
    return eat3Block;
}

- (void (^)())sleep3
{
    void (^sleep3Block)() = ^(){
        NSLog(@"%s",__FUNCTION__);
    };
    
    return sleep3Block;
}

//
- (Person *(^)())eat4
{
    Person * (^eat4Block)() = ^ {
        NSLog(@"%s",__FUNCTION__);
        return self;
    };
    return eat4Block;
}
//上下两种写法一样
- (Person *(^)())sleep4
{
    return ^ {
        NSLog(@"%s",__FUNCTION__);
        return self;
    };
}


//  with parameters
- (Person *(^)(NSString *))eat5
{
    Person * (^eat5Block)() = ^(NSString *foodName) {
        NSLog(@"吃: %@",foodName);
        return self;
    };
    return eat5Block;
}
//上下两种写法一样
- (Person *(^)(NSInteger))sleep5
{
    return ^(NSInteger hour) {
        NSLog(@"睡了%ld小时",(long)hour);
        return self;
    };
}


@end
